﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using web.data.entities;
using web.bussines;
using Webdiyer.WebControls.Mvc;
using System.Web.UI;
using web.core.Controllers;

namespace web.core.Models
{
    public class partnerModels
    {
        //get all get all
        public static PagedList<partners> adm_partner_plist(int pageindex, int pagesize, int language_id)
        {
             var obj = new partner_service();
             return obj.adm_partner_plist(pageindex, pagesize, language_id);
        }

        //get list partner for home
        public static List<partners> partner_list(int language_id)
        {
              var obj = new partner_service();
              return obj.partner_list(language_id);
        }

        public static int adm_partner_update(partners it)
        {
            var obj = new partner_service();
            return obj.adm_partner_update(it);
        }

        //enable - disable  
        public static int updateStatus(int id, bool is_vip)
        {
             var obj = new partner_service();
             return obj.updateStatus(id, is_vip);
        }

        //get items by id or code
        public static partners getByID(int id)
        {
            var obj = new partner_service();
            return obj.getByID(id);
        }

        //delete by id
        public static void deleteItem(int id)
        {
            var obj = new partner_service();
            //delete all images
            var item = getByID(id);
            if (item != null)
            {
                if (!string.IsNullOrEmpty(item.image_path1))
                    baseController.DeleteFile(item.image_path1);
                if (!string.IsNullOrEmpty(item.image_path2))
                    baseController.DeleteFile(item.image_path2);
            }
            //delete record in db
            obj.deleteItem(id);
        }
    }
}